<%--
  Created by IntelliJ IDEA.
  User: zjk
  Date: 2018-08-04
  Time: 14:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>添加明细模板</title>
    <link rel="shortcut icon" href="<c:url value="/easyui/css/images/favicon.ico" />"/>
    <link rel="stylesheet" href="<c:url value="/css/flipclock.css"/>"/>
    <link href="<c:url value="/css/CalcSS3.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/css/index.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/easyui/css/easyui.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/easyui/css/easyui_animation.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/easyui/css/easyui_plus.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/easyui/css/insdep_theme_default.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/easyui/css/icon.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/easyui/css/font-awesome-4.7.0/css/font-awesome.min.css"/>" rel="stylesheet"
          type="text/css"/>
    <!-- 引入 ECharts 文件 -->
    <script src="<c:url value="/js/echarts.js"/>"></script>
    <!--放入自定义的图表-->
    <script src="<c:url value="/js/monitor.js"/>"></script>
    <script type="text/javascript" src="<c:url value="/easyui/js/jquery.min.js"/>"></script>
    <script type="text/javascript" src="<c:url value="/easyui/js/jquery.easyui.min.js"/>"></script>
    <script type="text/javascript" src="<c:url value="/easyui/js/jquery.insdep-extend.min.js"/>"></script>
    <script type="text/javascript" src="<c:url value="/js/utils/DateFormate.js"/>"></script>

    <link href="<c:url value=" /css/utils/utilsDatagrid.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/css/utils/utilsForm.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/css/utils/utilsDetails.css"/>" rel="stylesheet" type="text/css"/>

</head>
<body>
<link href="<c:url value=" /css/utils/utilsDatagrid.css"/>" rel="stylesheet" type="text/css"/>
<link href="<c:url value="/css/utils/utilsForm.css"/>" rel="stylesheet" type="text/css"/>
<link href="<c:url value="/css/utils/utilsDetails.css"/>" rel="stylesheet" type="text/css"/>
<div class="easyui-layout" data-options="fit:true, border:false">
    <div data-options="region:'center'" style="padding:5px;">

        <form id="dr5hx-addCODetails-Form" method="post">
            <table id="dr5hx-addCODetails-table" class="utils-table" border="0" style="background-color: #EBEFF2;">
                <tr>
                    <td>产品名称：</td>
                    <td class="content-td" style="text-align: left;">
                        <input name="cOProductId" id="dr5hx-addCODetails-ProductName" class="easyui-combobox"
                               data-options="panelHeight:'auto'" width="300"/>

                    </td>
                    <td>产品编号：</td>
                    <td class="content-td" style="text-align: left;">
                        <input id="dr5hx-addCODetails-ProductNumber" class="easyui-textbox"
                               data-options="editable:false"/>
                    </td>
                </tr>
                <tr>
                    <td>单位：</td>
                    <td class="content-td" style="text-align: left;">
                        <input class="easyui-textbox" id="dr5hx-addCODetails-ProductUnit"
                               data-options="editable:false"/>
                    </td>
                    <td>售价：</td>
                    <td class="content-td" style="text-align: left;">
                        <input name="cOPrice" class="easyui-textbox" id="dr5hx-addCODetails-ProductPrice"
                               required="required"
                               validType="checkDotNumber"/>
                    </td>
                </tr>
                <tr>
                    <td>产品数量：</td>
                    <td class="content-td" style="text-align: left;">
                        <input name="cOAmount" class="easyui-textbox" id="dr5hx-addCODetails-ProductAccount"
                               required="required"
                               validType="checkNumber"/>
                    </td>
                    <td>总金额：</td>
                    <td class="content-td" style="text-align: left;">
                        <input name="cOMoney" id="dr5hx-addCODetails-ProductMoney" class="easyui-textbox"
                               data-options="editable:false"/>
                    </td>
                </tr>
                <tr>
                    <td>计划交付日期：</td>
                    <td class="content-td" style="text-align: left;">
                        <input name="cOTime" id="dr5hx-addCODetails-date" class="easyui-datebox"
                               data-options="width:250,labelWidth:70,editable:false" required="required"/>
                    </td>
                    <td>
                        成本价：
                    </td>
                    <td class="content-td" style="text-align: left;">
                        <input name="cOCostPrice" id="dr5hx-addCODetails-costprice" class="easyui-textbox"
                               data-options="width:250,labelWidth:70,editable:false" required="required"/>
                        <input id="dr5hx-addCODetailsForm-contractId" name="id" type="hidden" value="aa">
                    </td>
                </tr>
                <tr>
                    <td>备注：</td>
                    <td class="content-td" style="text-align: left;"><input name="cORemark"
                                                                            id="dr5hx-addCODetails-remark"
                                                                            class="easyui-textbox"
                                                                            data-options="width:350,labelWidth:70"/>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
<script type="text/javascript">
    $.extend($.fn.validatebox.defaults.rules, {
        checkDotNumber: {
            validator: function (value) {
                var pattern = /^\d+([.]\d+)*$/
                return pattern.test(value);
            },
            message: '必须为数字或小数'
        }
    });
    $.extend($.fn.validatebox.defaults.rules, {
        checkNumber: {
            validator: function (value) {
                var patrn = /^\d+$/;
                return patrn.test(value);
            },
            message: '必须为数字'
        }
    });

    $("#dr5hx-addCODetails-ProductName").combobox({
        url: '/saling/fuzzyQueryProductDetailsList',
        valueField: 'pid',
        textField: 'pname',
        prompt: '自动搜索',
        required: true,
        mode: 'remote',
        editable: true,
        method: 'post',
        hasDownArrow: false,
        limitToList: true,
        onBeforeLoad: function (param) {
            var value = $(this).combobox('getValue');
            if (value) {
                return true;
            }
            return false;
        },
        onSelect: function (rec) {
            $.post('/saling/exactQueryProductDetail', {id: rec.pid}, function (r) {
                if (r) {
                    $("#dr5hx-contract-load-edit-codetails").datagrid({'productDetail': r});
                    $("#dr5hx-addCODetails-ProductNumber").textbox({
                        value: r.pid
                    });
                    $("#dr5hx-addCODetails-ProductPrice").textbox({
                        value: r.poprice
                    });
                    $("#dr5hx-addCODetails-ProductUnit").textbox({
                        value: r.pwunit
                    });

                    $("#dr5hx-addCODetails-ProductAccount").textbox({
                        onChange: function (a, b) {
                            var c = $("#dr5hx-addCODetails-ProductPrice").textbox("getValue");
                            $("#dr5hx-addCODetails-ProductMoney").textbox({
                                value: c * a,
                            });
                        }
                    });
                    $("#dr5hx-addCODetails-ProductPrice").textbox({
                        onChange: function (a, b) {
                            var c = $("#dr5hx-addCODetails-ProductAccount").textbox("getValue");
                            $("#dr5hx-addCODetails-ProductMoney").textbox({
                                value: c * a,
                            });
                        }

                    });
                    $("#dr5hx-addCODetails-costprice").textbox({
                        value: r.pprice,
                    })
                }
            });

        }
    });
    if($("#dr5hx-contract-load-edit-dialog").dialog('options').contractId){
    $("#dr5hx-addCODetailsForm-contractId").val($("#dr5hx-contract-load-edi" +
        "t-dialog").dialog('options').contractId);}



</script>
</body>

</html>
